home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4262 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.5 KB  |  37 lines

  1. Path: server-b.cs.interbusiness.it!usenet
  2. From: albe@pinerolo.gvo.it (Alberto Velo)
  3. Newsgroups: comp.lang.c
  4. Subject: Watcom: pad a string ?
  5. Date: Thu, 01 Feb 1996 14:47:37 -0100
  6. Organization: Centro Servizi Interbusiness
  7. Message-ID: <ZCOExQTC3kJT089yn@pinerolo.gvo.it>
  8. Reply-To: albe@pinerolo.gvo.it
  9. NNTP-Posting-Host: 194.184.50.201
  10.  
  11. Is there a function to pad a string with a charachter, using Watcom C/C++ 10.5 
  12. ?
  13. I have an array, part of a structure (i.e. msg.from="Myname"); since array is 
  14. of defined length in the structure ( char from[36] ), I'd need to let msg.from 
  15. 36 chars length, padding it with spaces.
  16.  
  17. Else I need to know how to write the structure to a binary file: if I use a 
  18. sizeof(structname), while char arrays are shorter than the ones defined in the 
  19. struct, I find additional garbage chars in the file, who fill the array sizes.
  20. For example, I fill msg.from with "Myname"; from is defined as 3 chars array, 
  21. in the struct: when I write the entire struct to the file, the from field 
  22. appears to be "Myname   @ # *รจ 3 ..." , that is "Myname" + extra garbage for a 
  23. total of 36 chars.
  24.  
  25. If this can help, the structure is related to Fidonet PKTs.
  26. -- 
  27. Bye,   AL!
  28.         
  29.                      E-mail : albe@pinerolo.gvo.it
  30.    Team OS/2 ITA     Fidonet: 2:334/708 2:334/708.1
  31.                      OS2net : 81:439/63 81:439/63.1
  32.  
  33.             ***********************************************
  34.               Pinerolo Internetworking BBS +39-121-393945
  35.                        Telnet bbs.piw.gvo.it
  36.             ***********************************************
  37.